#include "rs485.h"

#define RS485_ENRX  HAL_GPIO_WritePin(RS485_EN_GPIO_Port, RS485_EN_Pin, GPIO_PIN_RESET)
#define RS485_ENTX  HAL_GPIO_WritePin(RS485_EN_GPIO_Port, RS485_EN_Pin, GPIO_PIN_SET)

uint8_t rs485RcvBuf[1024+16];
void RS485_Init(void)
{

    MX_USART6_UART_Init();
    RS485_ENRX;
    HAL_UARTEx_ReceiveToIdle_IT(RS485_USART_HANDLE, rs485RcvBuf, sizeof(rs485RcvBuf));
}

void RS485_Rcv_Start(void)
{
    HAL_UARTEx_ReceiveToIdle_IT(RS485_USART_HANDLE, rs485RcvBuf, sizeof(rs485RcvBuf));
}

uint32_t RS485_Tx(uint8_t* buf,uint16_t size)
{
    RS485_ENTX;
    HAL_UART_Transmit_IT(RS485_USART_HANDLE, buf, size);
    return 0;
}

void RS485_Tx_Cplt(void)
{
    RS485_ENRX;
}
